<?php
namespace cms\modules\common\filter;
use cms\modules\v1\models\access\ModuleActions;
use yii\base\ActionFilter;
use yii\web\MethodNotAllowedHttpException;
use yii\web\Response;

/**
 * Created by PhpStorm.
 * User: eycuit
 * Date: 2019/10/20
 * Time: 20:06
 */

class PermissionFilter extends ActionFilter {

    public function beforeAction($action)
    {
//        $permissionModel = new ModuleActions();
//        $result = $permissionModel->checkActions();
//
//        if ($result === true) {
            return true;
//        }
//
//        \Yii::$app->response->format = Response::FORMAT_JSON;
//
//        $this->handleError($result);
//
//        return false;

    }

    public function handleError($result = '') {
        throw new MethodNotAllowedHttpException($result);
    }

    public function afterAction($action, $result)
    {
        return parent::afterAction($action, $result); // TODO: Change the autogenerated stub
    }
}